﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using efuture.http;
using efuture.xml;
using System.Xml;
using System.IO;
using DevExpress.XtraEditors.DXErrorProvider;

namespace efuture.vdrp
{
    public partial class frmMain : DevExpress.XtraEditors.XtraForm
    {

        public frmMain()
        {
            InitializeComponent();
            InitializeValidationRules();
        }

        private void InitializeValidationRules() {
            // RequiredRule
            ConditionValidationRule RequiredRule = new ConditionValidationRule("RequiredRule", ConditionOperator.IsNotBlank);
            RequiredRule.ErrorText = "is required";


            this.dxValidationProvider1.SetValidationRule(Org_num, RequiredRule);
        }

        private void simpleButton3_Click(object sender, EventArgs e)
        {
            String url = String.Format("/mdm/customer/find?orgId={0}", "0" + edtOrgId.Text);
            String xml = HttpHelper.DoPost(url, "", null);
            //new XmlTextReader(new StringReader(xml));
            MessageBox.Show(xml.Length + "");
            XMLHelper.BindingData(panelControl6, new StringReader(xml), "/Root");
        }

        private void panel1_Paint(object sender, PaintEventArgs e)
        {
            int w = 0, h = 0;
            if (typeof(Control).IsAssignableFrom(sender.GetType()))
            {
                w = ((Control)sender).Width;
                h = ((Control)sender).Height;
            }
            else
            {
                return;
            }

            e.Graphics.DrawLine(new Pen(SystemColors.ControlLightLight), 0, 0, 0, h - 2);
            e.Graphics.DrawLine(new Pen(SystemColors.ControlLightLight), 0, 0, w - 2, 0);
            e.Graphics.DrawLine(new Pen(SystemColors.ControlDark), w - 2, h - 2, 0, h - 2);
            e.Graphics.DrawLine(new Pen(SystemColors.ControlLight), w - 1, h - 1, 0, h - 1);
            e.Graphics.DrawLine(new Pen(SystemColors.ControlDark), w - 2, h - 2, w - 2, 0);
            e.Graphics.DrawLine(new Pen(SystemColors.ControlLight), w - 1, h - 1, w - 1, 0);

        }

        private void simpleButton2_Click(object sender, EventArgs e)
        {
            //
            
            this.dxValidationProvider1.Validate();
        }

    }
}